﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CompanyControl.aspx.cs" Inherits="Thksoft.UserCotrols.CompanyControl" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>选择公司</title>
    <link href="../CSS/CompanyControl.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/correctpng.js" type="text/javascript"></script>
    <script src="/Scripts/jquery-1.4.1.js" type="text/javascript"></script>

    <base target="_self" />

    <script type="text/javascript">
        var ModalData = {
            Text:"",
            Value:""
        };
        function GetAllCheckBox(CheckAll) {
            var items = document.getElementsByTagName("input");
            for (i = 0; i < items.length; i++) {
                if (items[i].type == "checkbox") {
                    items[i].checked = CheckAll.checked;
                }
            }
        }
        function companyid() {
            var signatureID = document.getElementById("hidCompanyId").value;
            companyGo(signatureID);
        }
        function companyGo(signatureID) {
            var data = signatureID.split('%');
            ModalData.Text = data[0];
            ModalData.Value = data[1];
            //调用 父级页面关闭页面

            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            top.$("#layui-layer" + index + " .layui-layer-close").click();
            //top.layer.close(index);
            //top.layer.close(index);
            return;
            if (typeof window.showModalDialog == 'undefined') {
                //alert("写入的值:" + signatureID);
                localStorage.setItem("RETURN_VALUE", signatureID);
                //alert(localStorage.getItem("RETURN_VALUE"));
            }
            else {
                window.returnValue = signatureID;
            }
            window.close();
        }
        function FORM_CLOSE() {
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            top.$("#layui-layer" + index + " .layui-layer-close").click();
            top.layer.close(index);
        }
    </script>
    <script type="text/javascript">
        //TreeView全选与全不选
        function OnTreeNodeChecked() {
            var ele = event.srcElement;
            if (ele.type == 'checkbox') {
                var childrenDivID = ele.id.replace('CheckBox', 'Nodes');
                var div = document.getElementById(childrenDivID);
                if (div != null) {
                    var checkBoxs = div.getElementsByTagName('INPUT');
                    for (var i = 0; i < checkBoxs.length; i++) {
                        if (checkBoxs[i].type == 'checkbox')
                            checkBoxs[i].checked = ele.checked;
                    }
                }

                //OnTreeNodeChildChecked(ele);
            }
        }
        function OnTreeNodeChildChecked(ele) {
            //自动处理上级
            var parentDiv = ele.parentElement.parentElement.parentElement.parentElement.parentElement;
            var parentChkBox = document.getElementById(parentDiv.id.replace('Nodes', 'CheckBox'));
            if (parentChkBox != null) {
                var ChildsChkAll = true;
                var Boxs = parentDiv.getElementsByTagName('INPUT');
                for (var i = 0; i < Boxs.length; i++) {
                    if (Boxs[i].type == 'checkbox' && Boxs[i].checked == false) {
                        ChildsChkAll = false;
                    }
                }
                parentChkBox.checked = ChildsChkAll;
                OnTreeNodeChildChecked(parentChkBox);
            }
        }

        function Load() {
            document.getElementById("div").style.height = document.documentElement.clientHeight - 50;
        }
        function Load() {
            var winHeight = document.documentElement.clientHeight;
            var ob = document.getElementById("div");
            var mendingTop = ob.offsetTop;
            while (ob != null && ob.offsetParent != null && ob.offsetParent.tagName != "BODY") {
                mendingTop += ob.offsetParent.offsetTop;
                ob = ob.offsetParent;
            }
            if (winHeight - mendingTop - 60 > 5) {
                document.getElementById("div").style.height = winHeight - mendingTop - 60 + "px";
            }
            else {
                document.getElementById("div").style.height = "20px";
            }
        }
    </script>
</head>
<body onload="Load()">
    <form id="form1" runat="server">
        <asp:HiddenField ID="hidCompanyId" Value="" runat="server" />
        <asp:HiddenField ID="hidPCompanyId" Value="0" runat="server" />
        <div>
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td valign="top">
                        <div class="main_show_show" style="overflow-x: hidden; width: 100%;">
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tr>
                                    <td>
                                        <div id="div" style="overflow-y: auto; overflow-x: hidden;">
                                            <asp:TreeView ID="tvProcessUsers" ShowLines="True" runat="server" ShowCheckBoxes="All"
                                                onclick="OnTreeNodeChecked()" Height="350px" Width="100%">
                                                <ParentNodeStyle Font-Bold="False" />
                                                <HoverNodeStyle Font-Underline="False" ForeColor="Blue" />
                                                <SelectedNodeStyle Font-Underline="False" ForeColor="Blue" HorizontalPadding="0px"
                                                    VerticalPadding="0px" />
                                                <NodeStyle Font-Names="Tahoma" ForeColor="Black" HorizontalPadding="0px" NodeSpacing="0px"
                                                    VerticalPadding="0px" />
                                            </asp:TreeView>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <asp:Button ID="btnSure" runat="server" Text="确定" CssClass="bt_css_s" OnClick="btnSave_Click" />
                                        &nbsp;&nbsp;&nbsp;
                                    <asp:Button ID="btnCancel" runat="server" Text="取消" OnClientClick="FORM_CLOSE()"
                                        CssClass="bt_css_s" />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>